{
  "properties" : { },
  "id" : "f54691b9c2c5430fae80aceafb941be1",
  "script" : null,
  "groupId" : "b4225d8d7f6d47988e05788c9c671d66",
  "name" : "添加链路",
  "createTime" : 1727071059884,
  "updateTime" : 1726740627470,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "addLink",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n    \"target_device\": [\r\n        {\r\n            \"targetDeviceId\": \"D2173343257502001764\",\r\n            \"targetDeviceIp\": \"2.61.0.1\",\r\n            \"targetSysname\": \"SN2.R1\",\r\n            \"netRegion\": \"1\"\r\n        }\r\n    ],\r\n    \"local_device\": {\r\n        \"localDeviceId\": \"D1814237884760947677\",\r\n        \"localDeviceIp\": \"2.61.0.2\",\r\n        \"localSysname\": \"SN2.BD.R1\",\r\n        \"netRegion\": \"1\"\r\n    }\r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": 2\n}",
  "description" : null,
  "requestBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : null,
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "target_device",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Array",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ {
        "name" : "",
        "value" : "",
        "description" : "",
        "required" : false,
        "dataType" : "Object",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ {
          "name" : "targetDeviceId",
          "value" : "D2173343257502001764",
          "description" : "",
          "required" : false,
          "dataType" : "String",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ ]
        }, {
          "name" : "targetDeviceIp",
          "value" : "2.61.0.1",
          "description" : "",
          "required" : false,
          "dataType" : "String",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ ]
        }, {
          "name" : "targetSysname",
          "value" : "SN2.R1",
          "description" : "",
          "required" : false,
          "dataType" : "String",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ ]
        }, {
          "name" : "netRegion",
          "value" : "1",
          "description" : "",
          "required" : false,
          "dataType" : "String",
          "type" : null,
          "defaultValue" : null,
          "validateType" : "",
          "error" : "",
          "expression" : "",
          "children" : [ ]
        } ]
      } ]
    }, {
      "name" : "local_device",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ {
        "name" : "localDeviceId",
        "value" : "D1814237884760947677",
        "description" : "",
        "required" : false,
        "dataType" : "String",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "localDeviceIp",
        "value" : "2.61.0.2",
        "description" : "",
        "required" : false,
        "dataType" : "String",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "localSysname",
        "value" : "SN2.BD.R1",
        "description" : "",
        "required" : false,
        "dataType" : "String",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      }, {
        "name" : "netRegion",
        "value" : "1",
        "description" : "",
        "required" : false,
        "dataType" : "String",
        "type" : null,
        "defaultValue" : null,
        "validateType" : "",
        "error" : "",
        "expression" : "",
        "children" : [ ]
      } ]
    } ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : null,
    "defaultValue" : null,
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "code",
      "value" : "500",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "success",
      "value" : "false",
      "description" : "",
      "required" : false,
      "dataType" : "Boolean",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "",
      "description" : "",
      "required" : false,
      "dataType" : "Object",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "msg",
      "value" : "系统维护中，请稍后重试。",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : null,
      "defaultValue" : null,
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
import cn.hutool.core.lang.UUID;
ArrayList netDeviceLinkCharts = new ArrayList(2000);
body.target_device.stream().forEach(e -> {
    var netDeviceLinkChart={};
    netDeviceLinkChart.deviceId = (body.local_device.localDeviceId);
    netDeviceLinkChart.localDeviceIp = (body.local_device.localDeviceIp);
    netDeviceLinkChart.localSysname = (body.local_device.localSysname);
    int region = 0;
    if (e.netRegion == 2) {
        region = 10;
    } else if (e.netRegion == 3) {
        region = 20;
    }
    String localIfdesc = "GigabiEthernet" + UUID.randomUUID().toString().substring(0, 4) + "1/0." + region;
    String targetIfdesc = "Vlan-interface" + UUID.randomUUID().toString().substring(0, 4) + region;
    netDeviceLinkChart.localIfdesc=(localIfdesc);
    var l_index=new Random().nextInt(8999) + 1000 + "";
    netDeviceLinkChart.localIndex=(l_index);
    var date=new Date()
    netDeviceLinkChart.collectTime=(date);
    netDeviceLinkChart.ifAuto=(1);

    netDeviceLinkChart.targetDeviceid=(e.targetDeviceId);
    netDeviceLinkChart.targetDeviceip=(e.targetDeviceIp);
    netDeviceLinkChart.targetSysname=(e.targetSysname);
    netDeviceLinkChart.targetIfdesc=(targetIfdesc);
    var t_index=new Random().nextInt(899) + 100 + "";
    netDeviceLinkChart.targetIndex=(t_index);
    netDeviceLinkChart.deviceLinkName=(body.local_device.localSysname + "--->" + e.targetSysname);
    String id = body.local_device.localDeviceId + "_" + localIfdesc + "_" + netDeviceLinkChart.localIndex + "--->" + targetIfdesc + "_" + netDeviceLinkChart.targetIndex;
    netDeviceLinkChart.id=(id);
//拼接linkchart
var rs = {};
        rs.targetSysname=(netDeviceLinkChart.localSysname);
        rs.targetLocal=(netDeviceLinkChart.localTarget);
        rs.targetIndex=(netDeviceLinkChart.localIndex);
        rs.targetIftype=(netDeviceLinkChart.localIftype);
        rs.targetIfdesc=(netDeviceLinkChart.localIfdesc);
        rs.targetDeviceip=(netDeviceLinkChart.localDeviceIp);
        rs.targetDeviceid=(netDeviceLinkChart.deviceId);

        rs.runStatus=(netDeviceLinkChart.runStatus);

        rs.localTarget=(netDeviceLinkChart.targetLocal);
        rs.localSysname=(netDeviceLinkChart.targetSysname);
        rs.localIndex=(netDeviceLinkChart.targetIndex);
        rs.localIftype=(netDeviceLinkChart.targetIftype);
        rs.localIfdesc=(netDeviceLinkChart.targetIfdesc);
        rs.localDeviceIp=(netDeviceLinkChart.targetDeviceip);
        rs.deviceId=(netDeviceLinkChart.targetDeviceid);

        rs.linkLoad=(netDeviceLinkChart.linkLoad);

        String id = netDeviceLinkChart.targetDeviceid + "_" + netDeviceLinkChart.targetIfdesc+ "_" + netDeviceLinkChart.targetIndex+ "--->" + netDeviceLinkChart.localIfdesc + "_" + netDeviceLinkChart.localIndex;
        rs.id=(id);

        String deviceLinkName = netDeviceLinkChart.targetSysname + "_" + netDeviceLinkChart.targetIfdesc + "_" + netDeviceLinkChart.targetIndex+ "--->" + netDeviceLinkChart.localSysname + "_" + netDeviceLinkChart.localIfdesc + "_" + netDeviceLinkChart.localIndex;
        rs.deviceLinkName=(deviceLinkName);

        rs.collectTime=(netDeviceLinkChart.collectTime);
    var reversalNetDeviceLinkChart = rs;
    reversalNetDeviceLinkChart.deviceLinkName=(e.targetSysname + "--->" + body.local_device.localSysname);
    reversalNetDeviceLinkChart.ifAuto=(1);
    netDeviceLinkCharts.add(netDeviceLinkChart);
    netDeviceLinkCharts.add(reversalNetDeviceLinkChart);
});


return db.table("NET_DEVICE_LINK_CHART").primary("id").batchInsert(netDeviceLinkCharts);
